<#include "admin/home-exer.html"/>
<#macro main>
    <h3 class="field-title">大转盘</h3>
    <div class="data-cnt">
        <div style="position: relative">
            <img src="${resCtx}/images/ly3.png" id="image">
            <img src="${resCtx}/images/rotate-static.png" style="position: absolute;top:148px;left:148px;" id="start">
        </div>
        <p>抽奖结果：<span id="result">11==</span></p>
    </div>
</#macro>

<#macro tplJs>
    <script type="text/javascript" src="${resCtx}/js/plugins/jquery-rotate-master/jQueryRotateCompressed.js"></script>
    <script type="text/javascript">

        $(function(){
            $('#start').click(function(){
                doLottery();
            })
            doLottery();
        })

        function doLottery(){
            $.ajax({
                type:'get',
                url:ctx+'/admin/exer/doLottery',
                dataType:'json',
                success:function(resp){
                    var num = resp.data.id;
//                    console.info(resp.data);
                    $('#result').text(resp.data.prize);
                    $("#image").rotate({angle:0,duration:3000,animateTo:360*3-60*num});
                }
            })
        }

        function getRandomNum(Min,Max){
            var Range = Max - Min;
            var Rand = Math.random();
            return(Min + Math.round(Rand * Range));
        }
    </script>
</#macro>